#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
This is the base class of all other classes of the pydlink package. It works as
an abstract class, so you will find some methods that was not implemented here.

written by Arthur Furlan <arthur.furlan@gmail.com>
"""

import telnetlib

class DLink:

    def __init__(self, address, port):
        self.address = address
        self.port = port
        self.connected = False
        self.telnet = None

    def __del__(self):
        if self.telnet:
            self.telnet.close()
        self.connected = False

    def __str__(self):
        status = 'connected' if self.connected else 'not connected'
        return '%s (%s:%d -- %s)' % \
                (self.__class__.__name__, self.address, self.port, status)
